<?php
if( empty( $_SESSION ) )
{
	session_start();
}
header("Content-Type: text/html; charset=utf-8",true);

include_once("../../includes/restrito.php");
include_once("../models/cls.pagina.indice.php");

$oSumario = new pagina_indice();

if( ! empty( $_GET["acao"] ) )
{	
	switch( $_GET["acao"] )
	{
		case "editar" :
			$oSumario->select( $_GET["id"] );
			break;
			
		case "excluir" :
			$oSumario->delete( $_GET["id_delete"] , "../views/frm.edicao.controle.php?id=".$_SESSION["id_edicao"]."&nome=".$_SESSION["nome_edicao"] );
			break;
	}
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>IDIOMA</title>
<link rel="stylesheet" type="text/css" href="../../includes/sistema.css"/>
<script>
function _excluir(id)
{
	if(confirm("Por favor, confirme há remoção!"))
	{
		window.location.href="frm.pagina.indice.php?id_delete=" + id + "&acao=excluir";
	}	
}

function _revistaFilter(id_revista)
{
	window.location.href="frm.pagina.indice.php?id=" + id_revista + "&acao=revistaFilter";
}

function _salvar(){
	if(document.frm.titulo.value=="")
	{
		alert("Por favor, informe o título!!");
		document.frm.titulo.focus();
		return;
	}
	document.frm.submit();
}
function changeImagem(v)
{
	if(v==0)
	{
		document.getElementById("superior").style.display = "block";
		document.getElementById("inferior").style.display = "none";
	}
	else
	{
		document.getElementById("superior").style.display = "none";
		document.getElementById("inferior").style.display = "block";
	}
}
</script>
</head>
<body>
<div id="content">
  <h2>Adicionar item no sumário</h2>
  <hr size="1" noshade="noshade">
<form name="frm" method="post" action="../controllers/ctl.pagina.indice.php">
      <table width="600" border="0" align="center">
        <tr>
          <td colspan="3"><h2><?php echo $_SESSION["nome_edicao"];?></h2></td>
        </tr>
        <tr>
          <td colspan="3">Ordem:<br />
          <input name="ordem" type="text" class="form25px" value="<?php echo $oSumario->ordem; ?>" /></td>
        </tr>
        <tr>
          <td colspan="3">Título:
          <input name="titulo" type="text" class="form100pc" value="<?php echo $oSumario->titulo; ?>" /></td>
        </tr>
        <tr>
          <td colspan="3">Subtítulo:
          <input name="subtitulo" type="text" class="form100pc" value="<?php echo $oSumario->subtitulo; ?>" /></td>
        </tr>
        <tr>
          <td colspan="3">&nbsp;</td>
        </tr>
        <tr>
          <td align="left" valign="top"><input name="id" type="hidden" value="<?php echo $oSumario->id; ?>" />
            <input type="hidden" name="id_revista" value="<?php echo $_SESSION["id_edicao"]; ?>" />
            <input name="btnSubmit" type="button" class="formButton" value="SALVAR" onclick="_salvar()" />
          <input name="btnVoltar" type="button" class="formButton" value="VOLTAR" onclick="javascript:history.back();" />
          </td>
          <td align="right" valign="top">Posicionamento:<br />
            <select name="posicao" class="form" onchange="changeImagem(this.value)">
              <option value="0" <?php if( $oSumario->posicao == 0 ){echo " selected";}?>>Superior</option>
              <option value="1" <?php if( $oSumario->posicao == 1 ){echo " selected";}?>>Inferior</option>
          </select></td>
          <td width="238" align="left" valign="top">
          <?php
          if($oSumario->posicao == 0 )
		  {
			  $up = "block";
			  $down = "none";
		  }
		  else
		  {
			  $up = "none";
			  $down = "block";
		  }
		  ?>
          <div id="superior" style="display:<?php echo $up;?>;">
          <img src="../imagens/legenda.sumario.superior.gif" border="0" />
          </div>
          <div id="inferior" style="display:<?php echo $down;?>;">
          <img src="../imagens/legenda.sumario.inferior.gif" border="0" />
          </div>
          </td>
        </tr>
      </table>
</form>
</body>
</html>